import React,{useEffect,useState} from "react";

import style from './index.module.css'
import { Ivegetable } from "../SpecialOffer";
import axios from "axios";
import LikeItem from './LikeItem'

const {like,content} = style

export default function Like(){

    const [vegetableLike,setVegetableLike] = useState<Ivegetable[]>()

    useEffect(() => {
        
        axios.get('/api/vegetableClassification?type=喜欢&limit=0')
            .then(res=>{
                const result = res.data as Ivegetable[]
                setVegetableLike(result)
                
            })

    }, [])

    return (
        <div className={like}>
            <p>猜你喜欢</p>
            <ul className={content}>
                {
                    vegetableLike?.map(item=>{
                        return (
                            <LikeItem {...item} key={item._id} />
                        )
                    })
                }
            </ul>
        </div>
    )
}